/*
 * lane_model_fitting.h
 *
 *  Created on: May 11, 2018
 *      Author: geoff
 */

#ifndef RMD_LANE_HOUGH_LINE_H_
#define RMD_LANE_HOUGH_LINE_H_
#include <opencv2/core/core.hpp>
#include "lane_const_parameter.h"

namespace rmd {

class CustomHoughLineP {
 public:
  CustomHoughLineP();
  virtual ~CustomHoughLineP();

  void buuHoughLinesP(
      cv::Mat& _image, std::vector<cv::Vec4i>& _lines, int threshold,
      double minLineLength, double maxGap, int startY = 0,
      int endY = kImageHeight);

 private:
  void buuHoughLinesProbabilistic(
      CvMat* image, int threshold, int lineLength, int lineGap,
      std::vector<cv::Vec4i>& _lines, int linesMax, int startY = 0,
      int endY = 0);

  float cosValue[180] = {
      1.f,           0.999848f,   0.999391f,   0.99863f,    0.997564f,
      0.996195f,     0.994522f,   0.992546f,   0.990268f,   0.987688f,
      0.984808f,     0.981627f,   0.978148f,   0.97437f,    0.970296f,
      0.965926f,     0.961262f,   0.956305f,   0.951057f,   0.945519f,
      0.939693f,     0.93358f,    0.927184f,   0.920505f,   0.913545f,
      0.906308f,     0.898794f,   0.891007f,   0.882948f,   0.87462f,
      0.866025f,     0.857167f,   0.848048f,   0.838671f,   0.829038f,
      0.819152f,     0.809017f,   0.798635f,   0.788011f,   0.777146f,
      0.766044f,     0.754709f,   0.743145f,   0.731354f,   0.71934f,
      0.707107f,     0.694658f,   0.681998f,   0.66913f,    0.656059f,
      0.642787f,     0.62932f,    0.615661f,   0.601815f,   0.587785f,
      0.573576f,     0.559192f,   0.544639f,   0.529919f,   0.515038f,
      0.5f,          0.484809f,   0.469471f,   0.45399f,    0.438371f,
      0.422618f,     0.406736f,   0.390731f,   0.374606f,   0.358367f,
      0.342019f,     0.325567f,   0.309016f,   0.292371f,   0.275637f,
      0.258818f,     0.241921f,   0.22495f,    0.207911f,   0.190808f,
      0.173647f,     0.156434f,   0.139172f,   0.121868f,   0.104527f,
      0.0871547f,    0.0697554f,  0.0523349f,  0.0348984f,  0.0174513f,
      -1.11659e-006, -0.0174535f, -0.0349007f, -0.0523371f, -0.0697577f,
      -0.087157f,    -0.10453f,   -0.121871f,  -0.139174f,  -0.156436f,
      -0.173649f,    -0.19081f,   -0.207913f,  -0.224952f,  -0.241923f,
      -0.25882f,     -0.275639f,  -0.292373f,  -0.309018f,  -0.32557f,
      -0.342022f,    -0.358369f,  -0.374608f,  -0.390733f,  -0.406738f,
      -0.42262f,     -0.438372f,  -0.453992f,  -0.469473f,  -0.484811f,
      -0.500001f,    -0.515039f,  -0.52992f,   -0.54464f,   -0.559193f,
      -0.573577f,    -0.587786f,  -0.601815f,  -0.615662f,  -0.629321f,
      -0.642788f,    -0.656059f,  -0.669131f,  -0.681998f,  -0.694658f,
      -0.707106f,    -0.719339f,  -0.731353f,  -0.743144f,  -0.754709f,
      -0.766044f,    -0.777145f,  -0.78801f,   -0.798635f,  -0.809016f,
      -0.819151f,    -0.829037f,  -0.83867f,   -0.848047f,  -0.857166f,
      -0.866024f,    -0.874619f,  -0.882947f,  -0.891006f,  -0.898793f,
      -0.906307f,    -0.913544f,  -0.920504f,  -0.927183f,  -0.933579f,
      -0.939692f,    -0.945518f,  -0.951056f,  -0.956304f,  -0.961261f,
      -0.965925f,    -0.970295f,  -0.974369f,  -0.978147f,  -0.981626f,
      -0.984807f,    -0.987688f,  -0.990268f,  -0.992546f,  -0.994521f,
      -0.996194f,    -0.997564f,  -0.998629f,  -0.999391f,  -0.999848f};

  float sinValue[180] = {
      0.f,       0.0174524f, 0.0348995f, 0.052336f,  0.0697565f, 0.0871557f,
      0.104528f, 0.121869f,  0.139173f,  0.156434f,  0.173648f,  0.190809f,
      0.207912f, 0.224951f,  0.241922f,  0.258819f,  0.275637f,  0.292372f,
      0.309017f, 0.325568f,  0.34202f,   0.358368f,  0.374607f,  0.390731f,
      0.406737f, 0.422618f,  0.438371f,  0.45399f,   0.469471f,  0.48481f,
      0.5f,      0.515038f,  0.529919f,  0.544639f,  0.559193f,  0.573577f,
      0.587785f, 0.601815f,  0.615662f,  0.629321f,  0.642788f,  0.656059f,
      0.669131f, 0.681998f,  0.694659f,  0.707107f,  0.71934f,   0.731354f,
      0.743145f, 0.75471f,   0.766045f,  0.777146f,  0.788011f,  0.798636f,
      0.809017f, 0.819152f,  0.829038f,  0.838671f,  0.848048f,  0.857168f,
      0.866026f, 0.87462f,   0.882948f,  0.891007f,  0.898794f,  0.906308f,
      0.913546f, 0.920505f,  0.927184f,  0.933581f,  0.939693f,  0.945519f,
      0.951057f, 0.956305f,  0.961262f,  0.965926f,  0.970296f,  0.97437f,
      0.978148f, 0.981627f,  0.984808f,  0.987688f,  0.990268f,  0.992546f,
      0.994522f, 0.996195f,  0.997564f,  0.99863f,   0.999391f,  0.999848f,
      1.f,       0.999848f,  0.999391f,  0.998629f,  0.997564f,  0.996195f,
      0.994522f, 0.992546f,  0.990268f,  0.987688f,  0.984808f,  0.981627f,
      0.978147f, 0.97437f,   0.970295f,  0.965925f,  0.961261f,  0.956304f,
      0.951056f, 0.945518f,  0.939692f,  0.93358f,   0.927183f,  0.920504f,
      0.913545f, 0.906307f,  0.898793f,  0.891006f,  0.882947f,  0.874619f,
      0.866025f, 0.857167f,  0.848048f,  0.83867f,   0.829037f,  0.819152f,
      0.809017f, 0.798635f,  0.788011f,  0.777146f,  0.766044f,  0.75471f,
      0.743145f, 0.731354f,  0.71934f,   0.707107f,  0.694659f,  0.681999f,
      0.669131f, 0.65606f,   0.642788f,  0.629321f,  0.615662f,  0.601816f,
      0.587786f, 0.573578f,  0.559194f,  0.54464f,   0.529921f,  0.51504f,
      0.500002f, 0.484811f,  0.469473f,  0.453993f,  0.438373f,  0.42262f,
      0.406739f, 0.390734f,  0.374609f,  0.358371f,  0.342023f,  0.325571f,
      0.30902f,  0.292375f,  0.275641f,  0.258822f,  0.241925f,  0.224955f,
      0.207915f, 0.190813f,  0.173652f,  0.156438f,  0.139177f,  0.121874f,
      0.104533f, 0.0871601f, 0.069761f,  0.0523406f, 0.0349042f, 0.0174572f};
};
}

#endif
